*Set the base directory
local base "C:\Research\Alcohol and Morbidity\7. Code Archive"

*Set font to Times New Roman for export
graph set  eps  fontface "Times New Roman"
graph set  ps  fontface "Times New Roman"

*To create PDFs in older windows versions of Stata
  cap pr drop grexportpdf
  program define grexportpdf
    version  11
    args using
    loc using = subinstr("`using'",".pdf","",.)
    gr export "`using'.eps" , replace fontface("Times New Roman")
    !epstopdf "`using'.eps"
    *erase "`using'.eps"
  end
  
*Call programs that produce tables - requires OUTREG2
*Table 1 is produced by the SAS file "Table 1 Code.sas" 
include "`base'\Code for Figures and Tables in Paper\Table 2 Code.do" 
include "`base'\Code for Figures and Tables in Paper\Table 3 Code.do" 
*Table 4 is produced by "Table 4 Code.sas"      
  
*Call programs that produce figures  
include "`base'\Code for Figures and Tables in Paper\Figure 1 Code.do"  
include "`base'\Code for Figures and Tables in Paper\Figure 2 Code.do" 
include "`base'\Code for Figures and Tables in Paper\Figure 3 Code.do" 
include "`base'\Code for Figures and Tables in Paper\Figure 4 Code.do" 
 

*Call programs that produce appendices
include "`base'\Code for Appendices\Appendix 1 Code.do"
include "`base'\Code for Appendices\Appendix 2 Code.do"
include "`base'\Code for Appendices\Appendix 3 Code.do"
include "`base'\Code for Appendices\Appendix 4 Code.do"
include "`base'\Code for Appendices\Appendix 5 Code.do"
include "`base'\Code for Appendices\Appendix 6 Code.do"
include "`base'\Code for Appendices\Appendix 7 Code.do"
include "`base'\Code for Appendices\Appendix 8 Code.do"
include "`base'\Code for Appendices\Appendix 9 Code.do"


*Combine appendices - requires that PDFTK be installed
cd "`base'\Code for Appendices\"
!pdftk "Appendix 1.pdf"  "Appendix 2.pdf" "Appendix 3.pdf" "Appendix 4.pdf" "Appendix 5.pdf" "Appendix 6.pdf" "Appendix 7.pdf" "Appendix 8.pdf" "Appendix 9.pdf" cat output "WEB APPENDIX.pdf"

*Reset fonts to default ones
graph set  eps  fontface default
graph set  ps  fontface default

